<?php
$this->pageTitle = Yii::app()->name;
$this->breadcrumbs=array(
	'已有运输记录',
);
include_once('menu.php');
?>
<script>
<?php
if($alertMsg){
?>
alert('<?=$alertMsg?>');
<?php
}
?>
function del(id){
	if(!confirm('确认要删除本条记录（'+id+'）？')){
		return false;
	}
	$.post('<?php echo CHtml::normalizeUrl(array('/psi/TrackingDelete'));?>',{'TrackingIndex':id}, function (data) {
        var ret = $.parseJSON(data);
        if (ret != null && ret.success != null && ret.success) {
			alert(ret.msg);
			location.reload(true);
        }
	});	
}
</script>
<div style="width:100%; float:left; margin-bottom:10px; text-align:right;">
	<form action="" name="jobForm" id="jobForm" method="get">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="15%" class="td_right"><?php echo $labels['CarrierNo']; ?>: </td>
			<td width="35%"><input type="text" name="CarrierNo" value="<?php if(isset($search['CarrierNo']))echo $search['CarrierNo'];?>" id="CarrierNo" class="input_size4" /></td>
			<td width="15%" class="td_right"><?php echo $labels['EBoxNumber']; ?>: </td>
			<td><input type="text" name="EBoxNumber" value="<?php if(isset($search['EBoxNumber']))echo $search['EBoxNumber'];?>" id="EBoxNumber" class="input_size4" /></td>
		</tr>	
		<tr>
			<td class="td_right"><?php echo $labels['ShipDate']; ?>: </td>
			<td>
				<input type="text" name="ShipDate" id="ShipDate" value="<?= $search['ShipDate'] ?>" readonly="readonly" style="width:100px;" />
				<img onclick="displayCalendar(document.jobForm.ShipDate,'yyyy-mm-dd',this)" style="cursor:pointer;" src="images/calendar.png" />
			</td>
			<td class="td_right"><?php echo $labels['ArriveDate']; ?>: </td>
			<td>
				<input type="text" name="ArriveDate" id="ArriveDate" value="<?= $search['ArriveDate'] ?>" readonly="readonly" style="width:100px;" />
				<img onclick="displayCalendar(document.jobForm.ArriveDate,'yyyy-mm-dd',this)" style="cursor:pointer;" src="images/calendar.png" />
			</td>
		</tr>
		<tr>
			<td class="td_right"><?php echo $labels['ShippingType']; ?>: </td>			
			<td>
				<?php echo CHtml::dropDownList('ShippingType',$search['ShippingType'],Yii::app()->params['shippingType'],array('empty'=>array(''=>'请选择'),'class'=>'input_size6')); ?>
			</td>
			<td class="td_right"><?php echo $labels['ShippingStatus']; ?>: </td>			
			<td>
				<?php echo CHtml::dropDownList('ShippingStatus',$search['ShippingStatus'],Yii::app()->params['ShippingStatus'],array('empty'=>array(''=>'请选择'),'class'=>'input_size6')); ?>
			</td>
		</tr>
		<tr>
			<td colspan="4" style="text-align:right;">
				<a style="margin-right:50px;" href="<?=Yii::app()->createUrl('psi/exportTracking',$search)?>" target="_blank"><img src="images/down.png" border="0" /></a>
				<a style="margin-right:50px;" href="<?=Yii::app()->createUrl('psi/tracking',array('status'=>$_REQUEST['status']))?>"><img src="images/shua.png" border="0" /></a>
				<input type="image" src="images/go.png" name="jobSub" id="jobSub" value="Go" />
			</td>
		</tr>
	</table>				
		<input type="hidden" name="r" value="psi/tracking" />
		<input type="hidden" name="status" value="<?=$search['status']?>" />
	</form>
</div>
<form action="" name="trackingForm" id="trackingForm" method="post">
<table cellspacing="0" cellpadding="0" width="100%" class="tbl" style="float:left;">
	<tr class="head">
		<td width="2%"><input type="checkbox" name="checkAll" id="checkAll"></td>
		<td width="20%"><?php echo $labels['CarrierNo']; ?></td>
		<td width="10%"><?php echo $labels['EBoxNumber']; ?></td>
		<td width="10%"><?php echo $labels['ToLAMethod']; ?></td>
		<td width="10%"><?php echo $labels['ShippingStatus']; ?>: </td>
		<td><?php echo $labels['OETrackingStatus']; ?></td>
		<?php
		if($_REQUEST['status']!='Delivery'){
		?>
		<td width="6%">删除</td>
		<?php
		}
		?>
		<td width="6%">详情</td>
	</tr>
	<?php
    $i = 0;
    $cssArr = array(0 => 'even', 1 => 'odd', 2 => 'three');
    foreach ($rowTable as $item) {
        $trClass = $cssArr[$i % 3];
        $i++;
        ?>
	<tr class="<?= $trClass ?>">
		<td style="text-align:center;"><input type="checkbox" name="TrackingIndexs[]" id="<?=$item->TrackingIndex?>" value="<?=$item->TrackingIndex?>"></td>
		<td>
			<?=$item->CarrierNo?>
		</td>
		<td>
			<?=$item->EBoxNumber?>
		</td>
		<td>
			<?=$item->ShippingType?>
		</td>
		<td>
			<?=$item->ShippingStatus?>
		</td>
		<td>
			<?php echo CHtml::textField('OETrackingStatus_'.$item->TrackingIndex,$item->OETrackingStatus,array('style'=>'width:200px;')); ?>
		</td>
		<?php
		if($_REQUEST['status']!='Delivery'){
		?>
		<td style="text-align:center;">
			<a onclick="del('<?=$item->TrackingIndex?>')" href="###">删除</a>
		</td>
		<?php
		}
		?>		
		<td style="text-align:center;">
			<a href="<?=Yii::app()->createUrl('psi/trackingUpdate',array('trackingIndex'=>$item->TrackingIndex))?>">详情</a>
		</td>
	</tr>
	<?php
    }
    ?>
</table>
<div id="pager" align="center">
<?php  
	$this->widget('CLinkPager',array(  
		'header'=>'',  
		'firstPageLabel' => '<<',
		'lastPageLabel' => '>>',
		'prevPageLabel' => '<',
		'nextPageLabel' => '>',
		'pages' => $pages,  
		'maxButtonCount'=>13  
		));  
?>
</div>
<div style="width:100%; float:left; margin-top:10px; text-align:center;">
	<div style="text-align:center;"><input type="button" onclick="fxl()" name="multiSub" value="更新" /></div>	
</div>
</form>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
$(document).on('click','#checkAll',function() {
	var checked=this.checked;
	$("input[name='TrackingIndexs\[\]']").each(function() {this.checked=checked;});
});
$(document).on('click', "input[name='TrackingIndexs\[\]']", function() {
	$('#TrackingIndexs').prop('checked', $("input[name='TrackingIndexs\[\]']").length==$("input[name='TrackingIndexs\[\]']:checked").length);
});
});
function fxl(){
	var val = false;
	$("input:checkbox[name='TrackingIndexs\[\]']").each(function (){
    	if($(this).attr("checked")=='checked'){
			val = true;
        }
    });
	if(!val){
		alert('请选择需要更新的记录');
		return false;
	}
	document.forms.trackingForm.submit();
}
/*]]>*/
</script>